package leetcode.Y2024M6.review;

import org.junit.Test;

import java.util.Arrays;

public class S274 {
    public int hIndex(int[] citations) {
        Arrays.sort(citations);
        int hIndex=0;
        for (int i = citations.length-1; i >= 0; i--) {
            if (i<citations[i]){
                hIndex++;
            }else {
                break;
            }
        }
        return hIndex;
    }

    @Test
    public void test() {
        int[] arr = {1,3,1};
        System.out.println(hIndex(arr));

    }
}
